import 'package:flutter/material.dart';
import 'package:totaldemo/utils/util.dart';

class RecentPage extends StatefulWidget {
  const RecentPage({Key key}) : super(key: key);

  @override
  _RecentPageState createState() => _RecentPageState();
}

class _RecentPageState extends State<RecentPage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('最近浏览'),
      ),
      body: Wrap(
        children: <Widget>[
          buildContext(
              path: 'shopping_alpha.png', title: 'item1', color: Colors.red),
          buildContext(
              path: 'shopping2_alpha.png', title: 'item2', color: Colors.blue),
          buildContext(
              path: 'shopping3_alpha.png',
              title: 'item3',
              color: Colors.orange),
          buildContext(
              path: 'shopping4_alpha.png', title: 'item4', color: Colors.pink),
        ],
      ),
    );
  }

  Widget buildContext({String path, String title, Color color}) {
    return Column(
      children: [
        Padding(
          padding: const EdgeInsets.all(8.0),
          child: CircleAvatar(
            //圆角曲率
            radius: 40,
            child: Image.asset(
              Util.getUrl(path),
              height: 40,
              width: 40,
            ),
            // child: Image.asset(

            //   path,
            //   width: 40,
            //   height: 40,
            //   fit: BoxFit.fill,
            // ),
          ),
        ),
        Padding(
          padding: EdgeInsets.only(top: 10),
          child: Text(title),
        )
      ],
    );
  }
}
